package net.sansi.v3correctserver.service.correct;

import net.sansi.v3correctserver.exception.ServiceException;
import net.sansi.v3correctserver.task.AreaMergeTask;
import org.springframework.stereotype.Service;

/**
 * Created by Fang
 * create time : 2024/11/11
 * IDE : IntelliJ IDEA
 * <p>
 * 融合服务
 */

@Service
public class AreaMergeService {

    /**
     * 合并所有区域
     *
     * @return 合并结果
     */
    public boolean mergeAll(int target) {
        try {
            AreaMergeTask task = new AreaMergeTask(target);
            task.start();
            task.join();
            return true;
        } catch (Exception e) {
            throw new ServiceException("融合失败 [error] {}", e.getMessage());
        }
    }
}
